<div class="crumb-wrap">
    <div class="crumb-list"> <i class="icon-font"></i>
        <a href="<?=site_url()?>">首页</a>
        <span class="crumb-step">&gt;</span>
        <span class="crumb-name">银行卡管理</span>
    </div>
</div>
<div class="result-wrap">
    <form name="myform" id="myform" method="post">
        <div class="result-title">
            <div class="result-list">
                <?php if(empty($list)):?>
                    <a href="<?=site_url('bank/create')?>"> <i class="icon-font"></i>
                        您还没有添加提现银行卡， 点击新增银行卡
                    </a>
                <?php else:?>
                    <a href="<?=site_url('bank/create')?>"> <i class="icon-font"></i>
                        新增银行卡
                    </a>
                <?php endif;?>

                <a href="<?=site_url('extracted/show')?>">
                    查看提现记录
                </a>
            </div>
        </div>
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th>ID</th>
                    <th>开卡姓名</th>
                    <th>银行卡号</th>
                    <th>开户行（备注）</th>
                    <th>创建时间</th>
                    <th>操作</th>
                    <th>提现</th>
                </tr>
                <?php foreach($list as $k => $v):?>
                <tr>
                    <td><?=$v['id']?></td>
                    <td><?=$v['name']?></td>
                    <td><?=$v['number']?></td>
                    <td><?=$v['remarks']?></td>
                    <td><?=date('Y-m-d H:i:s',$v['create_date'])?></td>
                    <td>
                        <a class="link-update" href="<?=site_url('bank/update?bid='.$v['id'])?>">修改</a>
                        <a class="link-del" href="javascript:;" onclick="del_bank(<?=$v['id']?>)">删除</a>
                    </td>
                    <td>
                    	<a class="btn btn6 mr10 link-update btn-primary"  href="javascript:;" onclick="extracted(<?=$v['id']?>)">通过此卡提取</a>
                    </td>
                </tr>
                <?php endforeach;?>
            </table>
            <div class="list-page"><?=$page?></div>
        </div>
    </form>
</div>
<script>
	layer.config({
        extend: 'extend/layer.ext.js'
    });

	function del_bank(bid){
		layer.confirm('删除之后不可恢复，是否确定？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("<?=site_url('bank/delete')?>",{bid:bid},function(data){
            	if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
	}

	function extracted(bid){
		if(<?=$_SESSION['uinfo']['money']?> < 1000){
			layer.alert("您的积分余额小于1000，不能提现",{
                icon:2,
            });
            return false;
		}

		layer.prompt({
            title: '请输入提取积分：',
            formType: 0,
            maxlength: 10
        }, function(money){
            if(money < 1000){
            	layer.alert("请输入大于1000元的提现积分余额",{
	                icon:2,
	            });
	            return false;
            }

            $.post("<?=site_url('Extracted/create')?>",{money:money,bid:bid},function(data){
            	if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });

	}
</script>